import helpCtr from "../helps/helpCtr";

/**
 * @Author: 陈瑞鹏
 * @Date:   2022-12-08 09:39:35
 * @Last Modified by:   陈瑞鹏
 * @Last Modified time: 2023-01-31 14:16:44
 */
export default class barrackEntity {
  // { id: 14, iconUrl: "ele/master", harvest: 0, attack: 1, hp: 2, need: 200, name: "法师", desc: "发射火球，攻击3个单位", namePos: cc.v2(300, 80), poolName: "master", lock: 2000, attackAare: 300, speedXs: 1, quality: 4, isWar: false, isLock: false }
  public id: number = 0; //id
  public iconUrl: string = "";
  public harvest: number = 0; //采集
  public attack: number = 0;//攻击
  public hp: number = 0; //生命
  public num: number = 0; //一次生成数量
  private _need: number = 0; //创建一个所需金币
  public name: string = "";//名称
  public desc: string = ""; //描述
  public poolName: string = ""; //对象池名称
  public lock: number = 0; //解锁所需钻石
  public aoeNum: number = 0; //范围伤害人数
  public attackAare: number = 0; //攻击距离
  public speedXs: number = 1; //移动速度系数
  public gs: number = 0; //攻速
  public quality: number = 1; //品质
  public isWar: boolean = false; //是否在这个队伍中出战
  public isLock: boolean = true; //是否解锁
  public level: number = 1; //等级
  public fragment: number = 0; //碎片
  public cirCleType: string = ""; //圈的类型

  public init(val) {
    this.id = val.id;
    this.iconUrl = val.iconUrl;
    this.harvest = val.harvest || 0;
    this.attack = val.attack || 0;
    this.hp = val.hp || 0;
    this._need = val.need || 0;
    this.name = val.name || "";
    this.desc = val.desc || "";
    this.poolName = val.poolName || "";
    this.aoeNum = val.aoeNum || 0;
    this.lock = val.lock || 0;
    this.attackAare = val.attackAare || 0;
    this.speedXs = val.speedXs || 1;
    this.quality = val.quality || 1;
    this.num = val.num || 0;
    this.gs = val.gs || 0;
    this.cirCleType = val.cirCleType || "";
  }

  public get need() {
    return Math.ceil(this._need * (helpCtr.ins.goldXs || 1));
  }

  public set need(val) {
    this._need = val;
  }
}